package com.neshai.webapp.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

import static com.neshai.webapp.utils.EmailUtil.isValidEmail;

@Service
public class EmailService {
    @Autowired
    private JavaMailSender javaMailSender;


    public void sendSimpleMessage(String to, String subject, String text) {
        if (isValidEmail(to)) {
            SimpleMailMessage message = new SimpleMailMessage();
            message.setFrom("1584777471@qq.com");
            message.setTo(to);
            message.setSubject(subject);
            message.setText(text);
            javaMailSender.send(message);
        }
    }


}
